import request from '@/utils/request'

export default {
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params:{
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        userName: searchModel.userName,
        phone: searchModel.phone
      }
    });
  },
  addUser(user){
    return request({
      url: '/addUser',
      method: 'post',
      data: user
    });
  },
  updateUser(user){
    return request({
      url: '/updateUser',
      method: 'put',
      data: user
    });
  },
  saveUser(user){
    if(user.userName == null && user.userName == undefined){
      return this.addUser(user);
    }
    return this.updateUser(user);
  },
  getUserByName(userName){
    return request({
      //url: '/getUserByName/' + userName,
      url: `/getUserByName/${userName}`,
      method: 'get'
    });
  },
  deleteByName(userName){
    return request({
      url: `/deleteByName/${userName}`,
      method: 'delete'
    });
  },
}